package net.htjs.juc.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

//@Slf4j(topic = "c.Test1")
@Slf4j
public class ThreadDaemon {

    public static void main(String[] args) {
        Thread thread = new Thread(() ->{
            while(true) {
                if (Thread.currentThread().isInterrupted()) {
                    break;
                }
            }
            log.info("结束");
        }, "Daemon-Thread");
        try {
            thread.setDaemon(true);
            thread.start();
            TimeUnit.SECONDS.sleep(1);
            log.info("结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
